package com.example.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

/**
 * @author 朽
 */
public enum ReturnStatusEnum {
    TODO(0, "待处理"),
    RETURNING(1, "退货中"),
    COMPLETED(2, "已完成"),
    REJECTED(3, "已拒绝"),
    REVOKED(4, "已撤回"),
    AGREE(5, "已同意");

    /**
     * 状态码
     */
    @EnumValue
    private Integer code;
    /**
     * 状态描述
     */
    private String desc;

    ReturnStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据状态码获取描述
     *
     * @param code 状态码
     * @return 状态描述
     */
    public static String desc(Integer code) {
        for (ReturnStatusEnum status : ReturnStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status.desc;
            }
        }
        return "未知状态";
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
